package com.glorysoft.xztpda.model

import com.glorysoft.xztpda.base.BaseRepository
import com.glorysoft.xztpda.base.Constant
import com.glorysoft.xztpda.entity.*
import com.google.gson.JsonObject
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse


/**
 * FileName: LoginRepository
 * Author: XJH
 * Date: 2021/5/24 17:11
 * Description:
 * History:
 */
class LotRepository : BaseRepository() {

    suspend fun getLotInfo(map: JsonObject): LotInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.LOTQUERY"))
            .toResponse<LotInfoEntity>()
            .await()

    }

    suspend fun trackIn(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.LOTTRACKIN"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun getMaterialInfo(map: JsonObject): MaterielListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.XZTEQPQUERY"))
            .toResponse<MaterielListEntity>()
            .await()

    }

    suspend fun trackOut(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.LOTTRACKOUT"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun shiftChange(map: JsonObject): ChangeShiftEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.CHANGESHIFT"))
            .toResponse<ChangeShiftEntity>()
            .await()

    }

    suspend fun putLotComment(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.LOTEXCEPTIONMEMORANDUM"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun getShowFile(map: JsonObject): LotInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.FILELOOKUP"))
            .toResponse<LotInfoEntity>()
            .await()

    }

    suspend fun checkEqp(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.LOTQUERY"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun getORData(map: JsonObject): OrEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.QREXCEPTION"))
            .toResponse<OrEntity>()
            .await()

    }

    suspend fun submitOr(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.QREXCEPTION"))
            .toResponse<JsonObject>()
            .await()
    }

    suspend fun getItemEqp(map: JsonObject): ItemEqpEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.SUBEQPQUERY"))
            .toResponse<ItemEqpEntity>()
            .await()
    }

    suspend fun getLastLot(map: JsonObject): ItemEqpEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.FTENDLOT"))
            .toResponse<ItemEqpEntity>()
            .await()
    }

    suspend fun getEdcData(map: JsonObject): EdcDataEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.XZTGETEDCCURRENT"))
            .toResponse<EdcDataEntity>()
            .await()

    }

    suspend fun reportEdcData(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.XZTSAVEEDCDATA"))
            .toResponse<JsonObject>()
            .await()

    }


    suspend fun getLotEdcData(map: JsonObject): EdcDataEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.LOTQUERY"))
            .toResponse<EdcDataEntity>()
            .await()

    }

    suspend fun checkLotBinData(map: JsonObject): FTTrackOutEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.FTLOTTRACKOUT"))
            .toResponse<FTTrackOutEntity>()
            .await()
    }

    suspend fun ftTrackOut(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.FTLOTTRACKOUT"))
            .toResponse<JsonObject>()
            .await()

    }


    suspend fun getLotQty(map: JsonObject): ChangeShiftEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.CHANGESHIFT"))
            .toResponse<ChangeShiftEntity>()
            .await()

    }

    suspend fun getMosInfo(map: JsonObject): MosEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
            .addAll(getInJsonData(map,"XZT.XZTU8MOSQUERY"))
            .toResponse<MosEntity>()
            .await()

    }

    suspend fun checkMaterial(map: JsonObject): CheckMatEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/esbrest/RestService/postrequest")
                .addAll(getInJsonData(map,"XZT.XZTU8BOMITEMCHECK"))
                .toResponse<CheckMatEntity>()
                .await()

    }
}